﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WorkFlowSystem.Common;
using WorkFlowSystem.Business;
using WorkFlowSystem.DataBase;

namespace WorkFlowSystem
{
    
    public partial class LoginUi : Form
    {
        public LoginUi()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string account = textBoxX1.Text;
            string password = textBoxX2.Text;

            if (account.Length == 0)
            {
                MessageBox.Show("用户名不能为空。");
                return;
            }
            else if (password.Length == 0)
            {
                MessageBox.Show("密码不能为空。");
                return;
            }

            int uid = 0;
            int u_did = 0;
            Authority auth = Authority.UNKNOW;
            if (LoginVerification.Verifcation(account, password, ref uid, ref u_did, ref auth) < 0)
            {
                textBoxX2.Text = "";
            }
            else
            {
                CurrentUser.user_id = uid;
                CurrentUser.user_auth = auth;
                CurrentUser.user_did = u_did;
                this.DialogResult = DialogResult.OK;

                MessageBox.Show("登录成功！");
            }           
        } 

        private void button2_Click(object sender, EventArgs e)
        {
            MessageBox.Show("欢迎下次使用！");
            this.Close();
        }

        private void button3_Click(object sender, EventArgs e)
        {
           IpSetting ips = new IpSetting();
           ips.Show();

        }

    }
}
